package com.nju.edu.android_app;

import com.nju.edu.android_app.callback.WriteListener;
import com.weibo.sdk.android.api.StatusesAPI;
import com.weibo.sdk.android.demo.R;
import com.weibo.sdk.android.demo.R.layout;
import com.weibo.sdk.android.demo.R.menu;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class WriteActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_write);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.write, menu);
		return true;
	}

	public Handler handler=new Handler(){
		@Override
		public void handleMessage(Message msg) {
			Toast.makeText(WriteActivity.this, "发布成功", Toast.LENGTH_SHORT).show();
			WriteActivity.this.finish();
		}
	};
	
	public void back(View v){
		this.finish();
	}
	
	public void publish(View v){
		EditText et=(EditText)findViewById(R.id.edit_content);
		String str=et.getText().toString();
		if(str.equals("")){
			Toast.makeText(WriteActivity.this, "内容不能为空", Toast.LENGTH_SHORT).show();
			return;
		}
		StatusesAPI statusesApi=new StatusesAPI(MainActivity.accessToken);
		statusesApi.update(str, "0", "0", new WriteListener(this));
		
	}

}
